You are here: COM API reference > Designer object > OnShow method

OnShow method

Called when the user selects an interface extension page.

Parameters

FirstShow

Use this parameter to distinguish between the first time a page is shown (after InitWithData) and any later calls. OnShow can be called many times when the user switches between pages.

Remarks

The page can use this method to refresh or initialize the data it displays. This code should never be removed.

Following is the default extension of this method in the form templates:

Private Sub IAMExtensionPage_OnShow(ByVal FirstShow As Boolean)
    On Error GoTo Error_handler
    Dim Frame As IAMPagesFrame
    Dim state As AMEXTCOM_FLAGS
    
    If Not m_Designer Is Nothing Then
        m_Designer.OnShow Me, FirstShow
        On Error Resume Next
        Set Frame = m_Designer.GetHostService(SERVICE_PAGESFRAME)
        If Not Frame Is Nothing Then
            ' Frame.state(AMPPB_OK) = AMECF_ENABLED
        End If
        ' Todo
        ' Add your code here
    End If
    
    Exit Sub
Error_handler:
    MsgBox caption & " OnShow: " & Err.Description
End Sub

There are two reasons for initializing controls in OnShow instead of InitWithData. First, the values displayed may have changed since the InitWithData method was called. This can happen when the properties are edited from another page. Second, the page may never be shown. By delaying control initialization until OnShow, you ensure that it is only done when actually required. This will improve the responsiveness of the system.

Example

Private Sub IAMExtensionPage_OnShow(ByVal FirstShow As Boolean)
    On Error GoTo Error_handler
    
    If Not m_Designer Is Nothing Then
        m_Designer.OnShow Me, FirstShow
        ' Initialize the control
        txtDrawingNumber.Text = m_Designer.GetPropertyValue("",  "DrawingNumber_BSTR", "No Number")
    End If
    
    Exit Sub
Error_handler:
    MsgBox caption & " OnShow: " & Err.Description
End Sub

Related information

IAMExtensionPage interface

InitWithData method

OnHide method


www.bluecieloecm.com